﻿using System;
using System.Collections.Generic;

namespace Narwhunderful.Aphelia.Framework.IO.Serialization
{

    public abstract class SerializationSettings<T> where T : AdvancedSerializationSettings, new()
    {
        private T _advancedSettings;

        public T AdvancedSettings
        {
            get
            {
                if (_advancedSettings == default(T)) _advancedSettings = new T();
                return _advancedSettings;
            }
            set { _advancedSettings = value; }
        }

        public bool IncludeAssemblyVersionInTypeName { get; set; }
        public bool IncludeCultureInTypeName { get; set; }
        public bool IncludePublicKeyTokenInTypeName { get; set; }
    }

    public sealed class AdvancedSerializationXmlSettings : AdvancedSerializationSettings
    {
        public ISimpleValueConverter SimpleValueConverter { get; set; }
    }

    public sealed class AdvancedSerializationBinarySettings : AdvancedSerializationSettings
    {
    }

    public class AdvancedSerializationSettings
    {
        private PropertiesToIgnore _propertiesToIgnore;
        private IList<Type> _attributesToIgnore;

        ///<summary>
        ///</summary>
        public AdvancedSerializationSettings()
        {
            AttributesToIgnore.Add(typeof(NonSerializedAttribute));
            RootName = "Root";
        }

        public PropertiesToIgnore PropertiesToIgnore
        {
            get
            {
                if (_propertiesToIgnore == null) _propertiesToIgnore = new PropertiesToIgnore();
                return _propertiesToIgnore;
            }
            set { _propertiesToIgnore = value; }
        }

        public IList<Type> AttributesToIgnore
        {
            get
            {
                if (_attributesToIgnore == null) _attributesToIgnore = new List<Type>();
                return _attributesToIgnore;
            }
            set { _attributesToIgnore = value; }
        }

        public string RootName { get; set; }
        public ITypeNameConverter TypeNameConverter { get; set; }
    }
}
